home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / INTERVIE / BITMAP.H < prev    next >
C/C++ Source or Header  |  1991-12-19  |  3KB  |  117 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. /*
  24.  * Bitmap - a two-dimensional boolean mask
  25.  */
  26.  
  27. #ifndef bitmap_h
  28. #define bitmap_h
  29.  
  30. #include <InterViews/defs.h>
  31. #include <InterViews/resource.h>
  32.  
  33. class Font;
  34. class Transformer;
  35.  
  36. class Bitmap : public Resource {
  37. public:
  38.     Bitmap(const char* filename);
  39.     Bitmap(
  40.     char*, unsigned int width, unsigned int height, int x0 = 0, int y0 = 0
  41.     );
  42.     Bitmap(Font*, int);
  43.     Bitmap(Bitmap*);
  44.     ~Bitmap();
  45.  
  46.     void* Map();
  47.  
  48.     int Left();
  49.     int Right();
  50.     int Top();
  51.     int Bottom();
  52.     unsigned int Width();
  53.     unsigned int Height();
  54.  
  55.     void Transform(Transformer*);
  56.     void Scale(float sx, float sy);
  57.     void Rotate(float angle);
  58.  
  59.     void FlipHorizontal();
  60.     void FlipVertical();
  61.     void Rotate90();
  62.     void Rotate180();
  63.     void Rotate270();
  64.     void Invert();
  65.  
  66.     boolean Contains(int x, int y);
  67.     boolean Peek(int x, int y);
  68.     void Poke(boolean bit, int x, int y);
  69. private:
  70.     friend class Painter;
  71.  
  72.     class BitmapRep* rep;
  73. };
  74.  
  75. enum BitTx {NoTx, FlipH, FlipV, Rot90, Rot180, Rot270, Inv};
  76.  
  77. class BitmapRep {
  78. private:
  79.     friend class Bitmap;
  80.     friend class Painter;
  81.  
  82.     BitmapRep(const char* filename);
  83.     BitmapRep(char* data, unsigned int w, unsigned int h, int x, int y);
  84.     BitmapRep(Font*, int);
  85.     BitmapRep(BitmapRep*, BitTx);
  86.     BitmapRep(BitmapRep*, Transformer*);
  87.     ~BitmapRep();
  88.  
  89.     void Touch();
  90.     void PutBit(int x, int y, boolean bit);
  91.     boolean GetBit(int x, int y);
  92.     void* GetMap();
  93.     void* GetData();
  94.  
  95.     int ParseBitmapFile(const char*, char**);
  96.     void CreateWinFormat(char*, unsigned**);
  97.     boolean IsWinFormat(const char*);
  98.     void GetBitmapExt();
  99.     unsigned ReflectByte(unsigned);
  100.  
  101.     unsigned int width;
  102.     unsigned int height;
  103.     int x0;
  104.     int y0;
  105.     void* map;
  106.     void* data;
  107. };
  108.  
  109. inline int Bitmap::Left () { return -rep->x0; }
  110. inline int Bitmap::Right () { return rep->width - rep->x0 - 1; }
  111. inline int Bitmap::Top () { return rep->height - rep->y0 - 1; }
  112. inline int Bitmap::Bottom () { return -rep->y0; }
  113. inline unsigned int Bitmap::Width () { return rep->width; }
  114. inline unsigned int Bitmap::Height () { return rep->height; }
  115.  
  116. #endif
  117.